
import { useState,useCallback,memo } from 'react';
const   ButtonChild = memo(({handleClick}) =>{ 
  console.log('ButtonChild被渲染了');
  return  (<button onClick={handleClick}>加1</button>)
})
function Parent() {
  const [count, setCount] = useState(0);
  const [count2, setCount2] = useState(0);
  const handleClick = useCallback(() => {
    setCount(count+1);
  }, [count]);
  return (
    <div>
      <p>Count: {count}</p>
      <p>Count2: {count2}</p>
      <button onClick={() => setCount2(count2 + 1)}>增加 Count2 (子组件不渲染)</button>
      <ButtonChild handleClick={handleClick}/>
    </div>
  );
}
export default  Parent